home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 11 / Info-Mac_XI_Disc_1.cdr_ / Info-Mac XI Disc 1.cdr / Programs / Science & Math / MacEspresso 1.0 / espresso / sigma.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-28  |  1.6 KB  |  83 lines  |  [TEXT/R*ch]

  1. /* Module:sigma.c
  2.  * Purpose:
  3.  *    Contains routines for computing the signature cube of the given cube.
  4.  * Routines:
  5.  * pcube get_sigma():
  6.  *    Computes signature cube of the given cube d.
  7.  * void set_not():
  8.  */
  9.  
  10. #include <stdio.h>
  11. #include "espresso.h"
  12. #include "signature.h"
  13.  
  14. /*
  15.  * get_sigma:
  16.  * Objective: computes signature cube corresponding to the cube c
  17.  * Input:
  18.  *    R: OFFSET cover;
  19.  *    c: ONSET cube;
  20.  * Output:
  21.  *     signature cube
  22.  */
  23. pcube
  24. get_sigma(R,c)
  25. pcover R;
  26. register pcube c;
  27. {
  28.     pcover BB;
  29.     pcube out_part_r,s;
  30.     register pcube r,b;
  31.     register int i;
  32.         register int w, last;
  33.     register unsigned int x;
  34.  
  35.     out_part_r = new_cube();
  36.     s = new_cube();
  37.  
  38.     BB = new_cover(R->count);
  39.     BB->count = R->count;
  40.     /* BB = get_blocking_matrix(R,c); */
  41.     foreachi_set(R,i,r){
  42.         b = GETSET(BB,i);
  43.         if ((last = cube.inword) != -1) {
  44.             /* Check the partial word of binary variables */
  45.             x = r[last] & c[last];
  46.             x = ~(x | x >> 1) & cube.inmask;
  47.             b[last] = r[last] & (x | x << 1);
  48.             /* Check the full words of binary variables */
  49.             for(w = 1; w < last; w++) {
  50.                     x = r[w] & c[w];
  51.                     x = ~(x | x >> 1) & DISJOINT;
  52.                 b[w] = r[w] & (x | x << 1);
  53.             }
  54.             }
  55.         PUTLOOP(b,LOOP(r));
  56.         INLINEset_and(b,b,cube.binary_mask);
  57.         INLINEset_and(out_part_r,cube.mv_mask,r);
  58.         if(!setp_implies(out_part_r,c)){
  59.             INLINEset_or(b,b,out_part_r);
  60.         }
  61.     }
  62.     free_cube(out_part_r);
  63.     BB = unate_compl(BB);
  64.  
  65.     INLINEset_copy(s,cube.emptyset);
  66.     foreachi_set(BB, i, b) {
  67.         INLINEset_or(s,s,b);
  68.     }
  69.     free_cover(BB);
  70.     set_not(s);
  71.     return s;
  72. }
  73.  
  74.  
  75. /* set_not: flip 0 to 1 and 1 to 0 */
  76. void
  77. set_not(c)
  78. pcube c;
  79. {
  80.     INLINEset_diff(c,cube.fullset,c);
  81. }
  82.  
  83.